import pandas as pd

log = pd.read_csv("/Users/andre/Downloads/visit_log.csv", delimiter=';')

# создание колонки source_type
log['source_type'] = log['traffic_source']

# если источник traffic_source равен yandex или google, то в source_type ставится organic
log.loc[ (log['traffic_source'] == 'yandex') | (log['traffic_source'] == 'google'),'source_type'] = 'organic'

# для источников paid и email из России ставим ad
log.loc[ (  
    (log['traffic_source'] == 'email') | (log['traffic_source'] == 'paid') ) & 
    (log['region'] == 'Russia'),
    'source_type'] = 'ad'

# для источников paid и email не из России ставим other
log.loc[ (  
    (log['traffic_source'] == 'email') | (log['traffic_source'] == 'paid') ) & 
    (log['region'] != 'Russia'),
    'source_type'] = 'other'

log
